<style lang="less">
    /*@import '../../../styles/loading.less';*/
</style>
<style scoped>
    .pro-detail-content {
        padding-left: 20px;
        padding-right: 20px;
        margin-bottom: 50px;
    }

    .pro-detail-content .guanli {
        width: 20%;
        padding: 0;
        border-radius: 0 2px 2px 0;
    }

    .pro-detail-content .btn1 {
        display: inline-block;
        height: 20px;
        padding: 0 5px;
        margin: 0 5px;
        line-height: 18px;
        border-radius: 3px;
        border: 1px solid #c4c4c4;
    }

    #submit {
        border-radius: 20px;
        width: 200px;
    }

    #back {
        border-radius: 20px;
        margin-left: 20px;
        width: 120px;
    }

    .pro-detail-content .tagBox {
        border: 1px solid #d6d6d6;
        height: 36px;
        line-height: 36px;
        background-color: #f0f0f0;
        border-radius: 0 2px 2px 0;
    }

    .pro-detail-content .bgk {
        background-color: #edf2f6;
        padding-top: 20px;
        margin-bottom: 20px;
        padding-left: 20px;
    }

    .pro-detail-content .special {
        padding: 20px 20px;
        margin-bottom: 15px;
    }

    .pro-detail-content .special .ivu-form-item {
        margin-bottom: 15px;
    }

    .pro-detail-content .special .buttonBox {
        width: 100%;
        padding-right: 15px;
        margin-bottom: 15px;
    }

    .pro-detail-content .special .buttonBox .button {
        border-radius: 0;
        width: 100%;
    }

    .pro-detail-content .main .ivu-select,
    .main .ivu-input {
        border-radius: 0 2px 2px 0;
    }

    .common-box-body {
        padding-top: 24px;
    }

    .searchH3 {
        border-bottom: 1px solid #b3cad7;
    }
</style>
<style>
    .pro-detail-content
    .common-box-body
    .ivu-select-single
    .ivu-select-selection
    .ivu-select-placeholder,
    .common-box-body
    .ivu-select-single
    .ivu-select-selection
    .ivu-select-selected-value {
        padding-right: 0px;
    }

    .pro-detail-content .ivu-tabs.ivu-tabs-card > .ivu-tabs-bar .ivu-tabs-tab {
        color: #2d8cf0;
        border-color: transparent;
        background-color: #fff;
    }

    .pro-detail-content
    .ivu-tabs.ivu-tabs-card
    > .ivu-tabs-bar
    .ivu-tabs-tab-active {
        color: #808080;
        border: 1px solid #dddee1;
        border-bottom: 0;
    }

    .pdf-class,
    .pdf-class:hover {
        color: #3f75df;
        border: none;
        background-color: #edf2f6;
    }

    .pdf-class:focus {
        box-shadow: none;
    }

    #proModal.highlight_table .ivu-table .ivu-table-body tr.ivu-table-row-highlight td {
        height: 40px;
    }

    #proModal .ivu-table-large td {
        height: 40px;
    }

    .tableModal.highlight_table .ivu-table .ivu-table-body tr.ivu-table-row-highlight td {
        height: 40px;
    }

    .tableModal .ivu-table-large td {
        height: 40px;
    }
</style>

<template>
    <div class="pro-detail">
        <product-title></product-title>
        <div class="pro-detail-content ">
            <Form ref="proform" :model="proform" label-position="right" :rules="ruleValidate" id="main">
                <div class="common-box-header">
                    <h3>产品基本信息</h3>
                </div>
                <div class="common-box-body">
                    <Row>
                        <Col :md="24" :lg="6">
                        <FormItem label="供应商" prop="cid">
                            <Select v-model="proform.cid" @on-change="comChange" placeholder="请选择供应商" filterable>
                                <template v-for="item in all">
                                    <Option :value="item.cid" :key="item.cid">{{item.name}}</Option>
                                </template>
                            </Select>
                        </FormItem>
                        </Col>
                        <Col :md="24" :lg="6" class="col col1">
                        <FormItem label="产品名称" prop="name">
                            <Input v-model="proform.name" placeholder="请选择产品名称"
                                   style="width:80%;border-radius:0px !important;"></Input><Button type="info" class="guanli" @click="comChange1"
                                    >导入
                            </Button>
                        </FormItem>
                        </Col>
                        <Col :md="24" :lg="6">
                        <FormItem label="产品简称" prop="shortn">
                            <Input placeholder="请输入产品简称" v-model="proform.shortn"></Input>
                        </FormItem>
                        </Col>
                        <Col :md="24" :lg="6">
                        <FormItem label="产品代码" prop="pro_no">
                            <Input v-model="proform.pro_no" placeholder="请输入产品代码"></Input>
                        </FormItem>
                        </Col>
                    </Row>
                    <Row>
                        <Col :md="24" :lg="6">
                        <FormItem label="销售状态" prop="status">
                            <Select v-model="proform.status">
                                <Option value="1">在售</Option>
                                <Option value="2">停售</Option>
                            </Select>
                        </FormItem>
                        </Col>
                        <Col :md="24" :lg="6">
                        <FormItem label="主附险类型" prop="is_main">
                            <Select v-model="proform.is_main" @on-change="isMain">
                                <Option value="1">主险</Option>
                                <Option value="2">附加险</Option>
                                <Option value="3">组合险</Option>
                            </Select>
                        </FormItem>
                        </Col>
                        <Col :md="24" :lg="6">
                        <FormItem label="承保年龄">
                            <Input v-model="proform.limit_age" placeholder="例：0-65周岁"></Input>
                        </FormItem>
                        </Col>


                        <Col :md="24" :lg="6">
                        <FormItem label="产品分类">
                            <!-- <Select v-model="proform.cate_two" style="width:77%;margin-right:3%;" @on-change="fenleichange" label-in-value placeholder="请选择产品分类">
                                <i-option value=" ">不限</i-option>
                                <template v-for="(item,index) in fenleiArray">
                                    <template v-for="(item1,index1) in item.son">
                                       <i-option :value="item1.id" :key="item1.id" >{{item.name}}-----{{item1.name}}</i-option>
                                    </template>
                                </template>
                            </Select> -->
                            <i-select @on-change="cateChange" label-in-value v-model="cate" transfer filterable
                                      style="width:77%;margin-right:3%;" placeholder="请选择产品分类">
                                <i-option value=" ">不限</i-option>
                                <template v-for="(item,index) in fenleiArray">
                                    <template v-if="item.son&&item.son.length>0">
                                        <template  v-for="(item1,index1) in item.son" >
                                            <i-option :value="item1.id" :key="item1.id">{{item.name}}-----{{item1.name}}</i-option>
                                        </template>
                                    </template>
                                    
                                    <!-- <i-option :value="item.id" :key="item.id" v-if="item.son&&item.son.length==0"> -->
                                    <template  v-else>
                                        <i-option :value="item.id" :key="item.id">{{item.name}}</i-option>
                                    </template>
                                </template>
                            </i-select><Button type="info" class="guanli" @click="fenModal">
                                管理
                            </Button>
                        </FormItem>
                        </Col>

                    </Row>
                    <Row>
                        <Col :md="24" :lg="6" class="col col1">
                        <FormItem label="交费方式">
                            <i-input v-model="pay_typeCont" placeholder="请输入交费方式"
                                     style="width:80%;border-radius:0px !important;"></i-input><Button type="warning" class="guanli" @click="pay_typeAdd">添加</Button>
                        </FormItem>
                        </Col>
                        <Col :md="24" :lg="6" class="col" style="margin-bottom:24px;">
                        <Tag v-for="item in proform.pay_type" :key="item" :name="item" closable type="dot" color="blue"
                             @on-close="pay_typeRemove">{{item}}
                        </Tag>
                        </Col>
                    </Row>
                    <Row style="margin-bottom:24px;">
                        <i-col span="24">
                            <i-button type="warning" style="margin-bottom:10px;" @click="periodClick">
                                保险期间&nbsp;&nbsp;
                                <Icon type="plus"></Icon>
                            </i-button>
                            <template v-for="(item,index) in proform.period">
                                <Tag type="dot" closable color="blue" :key="item" @on-close="shanchu('period',index)">
                                    {{item}}
                                </Tag>
                            </template>
                        </i-col>
                        <i-col span="24">
                            <i-button type="warning" style="" @click="payPeriodClick">
                                交费期间&nbsp;&nbsp;
                                <Icon type="plus"></Icon>
                            </i-button>
                            <template v-for="(item,index) in proform.pay_period">
                                <Tag type="dot" closable color="blue" @on-close="shanchu('pay_period',index)">{{item}}
                                </Tag>
                            </template>
                        </i-col>
                    </Row>
                    <Row>
                        <i-col span="24" style="margin-bottom:24px;">
                            <Checkbox v-model="proform.has_radio">是否计折标系数</Checkbox>&emsp;
                            <Checkbox v-model="proform.has_fee">是否计费用政策</Checkbox>&emsp;
                            <Checkbox v-model="proform.is_show">是否独立展示</Checkbox>
                            <Checkbox v-model="proform.is_short">是否是短期消费险种</Checkbox>
                        </i-col>
                        <i-col span="24" style="margin-bottom:24px;" v-if="proform.is_main==1">
                            <Checkbox v-model="proform.has_plan">是否有依附主险计划</Checkbox>&emsp;
                        </i-col>
                        <Col :md="24" :lg="10" v-if="proform.has_plan&&proform.is_main==1">
                        <FormItem label="计划名称">
                            <Input v-model="proform.plan_name" placeholder="请输入计划名称"></Input>
                        </FormItem>
                        </Col>
                        <i-col span="24" v-if="proform.has_plan&&proform.is_main==1">
                            <i-button type="primary" style="margin-bottom:10px;" @click="add_must_pro">
                                必选附加险&nbsp;&nbsp;
                                <Icon type="plus"></Icon>
                            </i-button>
                            <template v-for="(item,index) in must_pro">
                                <Tag type="dot" closable color="blue" :key="item.pro_mid"
                                     @on-close="shanchu1('must_pro',index)">{{item.name}}
                                </Tag>
                            </template>
                        </i-col>
                        <i-col span="24" style="margin-bottom:24px;" v-if="proform.has_plan&&proform.is_main==1">
                            <i-button type="warning" style="" @click="add_non_must_pro">
                                推荐附加险&nbsp;&nbsp;
                                <Icon type="plus"></Icon>
                            </i-button>
                            <template v-for="(item,index) in non_must_pro">
                                <Tag type="dot" closable color="blue" :key="item.pro_mid"
                                     @on-close="shanchu1('non_must_pro',index)">{{item.name}}
                                </Tag>
                            </template>
                        </i-col>
                    </Row>

                </div>
                <div class="common-box-header" v-if="proform.is_main==3">
                    <h3>
                        保障计划类别
                        &emsp;&emsp;
                        <Button class="pdf-class" style="" @click="addPlan">
                            <Icon type="plus-round"></Icon>&nbsp;
                            新增
                        </Button>
                    </h3>

                </div>
                <div class="common-box-body" v-if="proform.is_main==3">
                    <div style="color:red">
                        注：附加险不能为空
                    </div>
                    <template v-for="(item,index) in plan">
                        <Row>
                            <Col :md="24" :lg="10">
                            <FormItem label="保障计划名称">
                                <Input v-model="proform.plan[index].plan_type" placeholder="请输入计划名称"></Input>
                            </FormItem>
                            </Col>
                            <i-col span="24">
                                <i-button type="primary" style="margin-bottom:10px;" @click="add_more_must(index)">
                                    必选附加险&nbsp;&nbsp;
                                    <Icon type="plus"></Icon>
                                </i-button>
                                <template v-for="(item1,index1) in plan[index].main_pro">
                                    <Tag type="dot" closable color="blue" :key="item1.id"
                                         @on-close="shanchu1('more_must',index,index1)">{{item1.name}}
                                    </Tag>
                                </template>
                            </i-col>
                            <i-col span="24" style="margin-bottom:24px;">
                                <i-button type="warning" style="" @click="add_more_tuijian(index)">
                                    推荐附加险&nbsp;&nbsp;
                                    <Icon type="plus"></Icon>
                                </i-button>
                                <template v-for="(item1,index1) in plan[index].addi_pro">
                                    <Tag type="dot" closable color="blue" @on-close="shanchu1('more_no_must',index,index1)"
                                         :key="item1.id">{{item1.name}}
                                    </Tag>
                                </template>
                            </i-col>
                        </Row>
                    </template>
                </div>

                <div class="common-box-header mb15">
                    <h3>
                        条款信息资料
                        &emsp;&emsp;
                        <input type="file" id="pdfFile" style="display:none;" @change="pdfFile1($event)">
                        <Button class="pdf-class" style="" @click="pdfFile" v-if="!proform.pdf_path">
                            <i class="iconfont">&#xe63a;</i>
                            上传PDF
                        </Button>
                        <!-- <input type="file" id="pdfFile" style="display:none;" @change="pdfFile1($event)"> -->
                        <Button class="pdf-class" style="" v-if="proform.pdf_path" @click="seePdf">
                            <i class="iconfont">&#xe611;</i>
                            查看原PDF条款
                        </Button>
                    </h3>
                </div>
                <!-- <Row class="bgk" style="margin-bottom:15px;">
                    <Col :md="24" :lg="3" class="pdfBox">
                            <input type="file" id="pdfFile" style="display:none;" @change="pdfFile1($event)">
                            <Button type="success" class="guanli" style="width:100%;" @click="pdfFile">
                                <Icon type="plus" ></Icon>
                                上传PDF
                            </Button>
                    </Col>
                    <Col :md="24" :lg="21" class="bgd" style="height:60px;">
                            <Tag  type="dot" color="blue" v-if="proform.pdf_name" style="margin-left: 10px;" closable @on-close="handleClose2">{{proform.pdf_name}}</Tag>
                    </Col>
                </Row> -->
                <Row>
                    <Col :md="24" :lg="24">
                    <Tabs type="card" :animated="false">
                        <TabPane label="保险责任">
                            <UE :defaultMsg="proform.rights"  ref="rights" id="rights"></UE>                        
                        </TabPane>
                        <TabPane label="投保规则">
                            <UE :defaultMsg="proform.rule"  ref="rule" id="rule"></UE>
                        </TabPane>
                        <TabPane label="责任免除">
                            
                            <UE :defaultMsg="proform.exclusion"  ref="exclusion" id="exclusion" ></UE>
                        </TabPane>
                        <TabPane label="案例说明">
                            
                            <UE :defaultMsg="proform.cases"  ref="cases" id="cases" ></UE>
                        </TabPane>
                        <TabPane label="详细条款">
                            
                            <UE :defaultMsg="proform.clause"  ref="clause" id="clause" ></UE>
                        </TabPane>
                        <TabPane label="病种详情">
                            
                            <UE :defaultMsg="proform.illness"  ref="illness" id="illness" ></UE>
                        </TabPane>
                        <TabPane label="险种描述">
                            <UE :defaultMsg="proform.description"  ref="description" id="description"></UE>
                        </TabPane>
                    </Tabs>
                    </Col>
                </Row>
            </Form>
            <div id="footer" class="pt22">
                <Button type="primary" shape="circle" id="submit" @click="handleSubmit('proform')"
                        style="border-radius: 30px !important;">
                    <Icon type="checkmark-circled"></Icon>
                    保存 / 提交
                </Button>
                <Button id="back" shape="circle" @click="back" style="border-radius: 30px !important;">返回</Button>
            </div>
        </div>

        <Modal
            v-model="modal1"
            title="分类管理"
            width="900px"
            class="fenlei"
            :mask-closable="false"
        >
            <Row style="height:400px;">
                <i-col :md="14" :lg="14" class="pr15"
                       style="padding:16px;height:100%;overflow:scroll;overflow-x:hidden;">
                    <div>
                        <template v-for="(item,index) in fenleiArray">
                            <div class="zhu">
                                <span class="" class="pointer" @click="true1(index)">
                                    <Icon type="chevron-up" class="ml15 mr10" v-if="xianshi==index"></Icon>
                                    <Icon type="chevron-down" class="ml15 mr10 pointer" v-else></Icon>
                                </span>
                                <input type="text" v-if="bianji==index" v-model="bianjiCont" class="outLine">
                                <span v-else class="" style="color:#4D7FE4;">{{item.name}}</span>
                                <span class="fr caozuo create" @click="bianji1(index,item.id)" v-if="bianji==index"
                                      style="background-color:#18BF6D;">
                                    <Icon type="checkmark-round"></Icon>
                                </span>
                                <span class="fr caozuo create" @click="bianji1(index,item.id)" v-else>
                                    <Icon type="android-create"></Icon>
                                </span>
                                <span class="fr caozuo del" @click="delete1(item.id)">
                                    <Icon type="trash-a"></Icon>
                                </span>
                            </div>
                            <div class="fu" v-if="xianshi==index">
                                <template v-for="(item1,index1) in item.son">
                                    <div class="list">
                                        <Icon class="ml15"></Icon>
                                        ---------&nbsp;&nbsp;
                                        <!-- <input type="text"> -->
                                        <input type="text" v-if="bianjiTwo == index1" v-model="bianjiCont1">
                                        <span v-else>{{item1.name}}</span>
                                        <span class="fr caozuo create" @click="bianji2(index,index1,item1.id)"
                                              v-if="bianjiTwo==index1" style="background-color:#18BF6D;">
                                            <Icon type="checkmark-round"></Icon>
                                        </span>
                                        <span class="fr caozuo create" @click="bianji2(index,index1,item1.id)" v-else>
                                            <Icon type="android-create"></Icon>
                                        </span>
                                        <span class="fr caozuo del" @click="delete1(item1.id)">
                                            <Icon type="trash-a"></Icon>
                                        </span>
                                    </div>
                                </template>
                            </div>
                        </template>

                    </div>
                </i-col>
                <i-col :md="10" :lg="10" style="padding:15px;background-color:#CEEAF7;height:100%;">
                    <h3 class="searchH3 mt16" x>添加分类</h3>
                    <Form ref="fenleiForm" :model="fenleiForm" label-position="left" :label-width="80" id="fenleiForm">
                        <i-col :md="24" :lg="24">
                            <FormItem label="上级分类" prop="cate_first" class="bian">
                                <i-select placeholder="请选择上级分类" v-model="fenleiForm.pid">
                                    <i-option value="0">根分类</i-option>
                                    <template v-for="(item,index) in cateFirst">
                                        <i-option :value="item.id" :key="item.name">{{item.name}}</i-option>
                                    </template>
                                </i-select>
                            </FormItem>
                        </i-col>
                        <i-col :md="24" :lg="24">
                            <FormItem label="分类名称" prop="cate_two" class="bian">
                                <Input type="text" placeholder="请输入分类名称" v-model="fenleiForm.name">
                                </Input>
                            </FormItem>
                        </i-col>
                        <i-col :md="24" :lg="24" class="tCenter">
                            <i-button type="primary" shape="circle" @click="cate_create">
                                <Icon class="iconfont icon-dui" style="font-size:14px;"></Icon>&emsp;
                                新增分类
                            </i-button>
                        </i-col>
                    </Form>
                </i-col>
            </Row>
        </Modal>
        <Modal
            v-model="modal2"
            title="保险期间"
            okText="关闭"
            cancelText=" "
        >
            <Row>
                <CheckboxGroup v-model="proform.period">
                    <template v-for="item in period.all_period">
                        <Col span="6">
                        <Checkbox :label="item">
                            <span>{{item}}</span>
                        </Checkbox>
                        </Col>
                    </template>
                </CheckboxGroup>
            </Row>
        </Modal>
        <Modal
            v-model="modal3"
            title="交费期间"
            okText="关闭"
            cancelText=" "
        >
            <Row>
                <CheckboxGroup v-model="proform.pay_period">
                    <template v-for="item in period.all_pay_period">
                        <Col span="6">
                        <Checkbox :label="item">
                            <span>{{item}}</span>
                        </Checkbox>
                        </Col>
                    </template>
                </CheckboxGroup>
            </Row>
        </Modal>
        <Modal
            v-model="pro_modal"
            title="产品列表"
            okText="关闭"
            cancelText=" "
            :mask-closable="false"
            width="600"
        >
            <div>
                <div class="common-box-body">
                    <Row>
                        <Form :model="pro_modal_form">
                            <i-col span="10">
                                <FormItem label="险种简称">
                                    <Input v-model="pro_modal_form.shortn"></Input>
                                </FormItem>
                            </i-col>
                            <i-col span="10">
                                <FormItem label="主附险类型">
                                    <Select v-model="pro_modal_form.is_main">
                                        <Option value="1">主险</Option>
                                        <Option value="2">附加险</Option>
                                        <Option value="3">组合险</Option>
                                    </Select>
                                </FormItem>
                            </i-col>
                            <i-col span="2">
                                <i-button type="primary" @click="pro_search">
                                    <Icon type="ios-search"></Icon>
                                    搜索
                                </i-button>
                            </i-col>
                        </Form>
                    </Row>
                    <Row>
                        <i-col>
                            <div class="" id="proModal">
                                <Table size="large" stripe border :columns="columns1" :data="prolist" class="">
                                </Table>
                            </div>
                        </i-col>
                    </Row>
                    <Row type="flex" justify="end" class="code-row-bg">
                        <Col style="margin-top: 24px;">
                        <Page ref="pages" :total="listTotal" @on-change="pageChange"
                              placement="top" class="page" :page="pro_modal_form.p" :pageSize="pro_modal_form.pagesieze" ></Page>
                        </Col>
                    </Row>
                </div>
            </div>
        </Modal>
        <Modal
            v-model="must_pro_modal"
            title="必选附加险"
            okText="关闭"
            cancelText=" "
            width="600"
            :mask-closable="false"
        >
            <div class="common-box-body">
                <Row>
                    <Form :model="must_pro_modal_form">
                        <i-col span="10">
                            <FormItem label="险种简称">
                                <Input v-model="must_pro_modal_form.name"></Input>
                            </FormItem>
                        </i-col>
                        <i-col span="10">
                            <FormItem label="主附险类型">
                                <Select v-model="must_pro_modal_form.is_main">
                                    <Option value="1">主险</Option>
                                    <Option value="2">附加险</Option>
                                </Select>
                            </FormItem>
                        </i-col>
                        <i-col span="2">
                            <i-button type="primary" @click="plan_must_search_click">
                                <Icon type="ios-search"></Icon>
                                搜索
                            </i-button>
                        </i-col>
                    </Form>
                </Row>
                <Row>
                    <div class="tableModal">
                        <Table size="large" stripe border :columns="columns2" :data="sole_bixuan" class=""></Table>
                    </div>
                    <Row type="flex" justify="end" class="code-row-bg">
                        <Col style="margin-top: 24px;">
                        <Page ref="pages" :current="must_pro_modal_form.p" :total="table_modal_total"
                              @on-change="planMustPageChange" placement="top" class="page"></Page>
                        </Col>
                    </Row>
                </Row>
            </div>

        </Modal>
        <Modal
            v-model="addi_pro_modal"
            title="推荐附加险"
            okText="关闭"
            cancelText=" "
            :mask-closable="false"
        >
            <div class="common-box-body">
                <Row>
                    <Form :model="must_tuijian_modal_form">
                        <i-col span="10">
                            <FormItem label="险种简称">
                                <Input v-model="must_tuijian_modal_form.name"></Input>
                            </FormItem>
                        </i-col>
                        <i-col span="10">
                            <FormItem label="主附险类型">
                                <Select v-model="must_tuijian_modal_form.is_main">
                                    <Option value="1">主险</Option>
                                    <Option value="2">附加险</Option>
                                </Select>
                            </FormItem>
                        </i-col>
                        <i-col span="2">
                            <i-button type="primary" @click="plan_tuijian_search_click">
                                <Icon type="ios-search"></Icon>
                                搜索
                            </i-button>
                        </i-col>
                    </Form>
                </Row>
                <Row>
                    <div class="tableModal">
                        <Table size="large" stripe border :columns="columns2" :data="sole_tuijian" class=""></Table>
                    </div>
                    <Row type="flex" justify="end" class="code-row-bg">
                        <Col style="margin-top: 24px;">
                        <Page ref="pages" :current="must_tuijian_modal_form.p" :total="table_modal_total"
                              @on-change="planTuijianPageChange" placement="top" class="page"></Page>
                        </Col>
                    </Row>

                </Row>
            </div>

        </Modal>
        <Modal
            v-model="more_must_modal"
            title="保障计划必选附加险"
            okText="关闭"
            cancelText=" "
            :mask-closable="false"
        >
            <div class="common-box-body">
                <Row>
                    <Form :model="bz_must_form">
                        <i-col span="10">
                            <FormItem label="险种简称">
                                <Input v-model="bz_must_form.name"></Input>
                            </FormItem>
                        </i-col>
                        <i-col span="10">
                            <FormItem label="主附险类型">
                                <Select v-model="bz_must_form.is_main">
                                    <Option value="1">主险</Option>
                                    <Option value="2">附加险</Option>
                                </Select>
                            </FormItem>
                        </i-col>
                        <i-col span="2">
                            <i-button type="primary" @click="bz_must_search_click">
                                <Icon type="ios-search"></Icon>
                                搜索
                            </i-button>
                        </i-col>
                    </Form>
                </Row>
                <Row>
                    <div class="tableModal">
                        <Table size="large" stripe border :columns="columns3" :data="sole_tuijian" class=""></Table>
                    </div>
                    <Row type="flex" justify="end" class="code-row-bg">
                        <Col style="margin-top: 24px;">
                        <Page ref="pages" :current="bz_must_form.p" :total="table_modal_total"
                              @on-change="bzMustPageChange" placement="top" class="page"></Page>
                        </Col>
                    </Row>
                </Row>
            </div>

        </Modal>
        <Modal
            v-model="more_addi_modal"
            title="保障计划推荐附加险"
            okText="关闭"
            cancelText=" "
            :mask-closable="false"
        >
            <div class="common-box-body">
                <Row>
                    <Form :model="bz_tuijian_form">
                        <i-col span="10">
                            <FormItem label="险种简称">
                                <Input v-model="bz_tuijian_form.name"></Input>
                            </FormItem>
                        </i-col>
                        <i-col span="10">
                            <FormItem label="主附险类型">
                                <Select v-model="bz_tuijian_form.is_main">
                                    <Option value="1">主险</Option>
                                    <Option value="2">附加险</Option>
                                </Select>
                            </FormItem>
                        </i-col>
                        <i-col span="2">
                            <i-button type="primary" @click="bz_tuijian_search_click">
                                <Icon type="ios-search"></Icon>
                                搜索
                            </i-button>
                        </i-col>
                    </Form>
                </Row>
                <Row>
                    <div class="tableModal">
                        <Table size="large" stripe border :columns="columns3" :data="sole_tuijian" class=""></Table>
                    </div>
                    <Row type="flex" justify="end" class="code-row-bg">
                        <Col style="margin-top: 24px;">
                        <Page ref="pages" :current="bz_tuijian_form.p" :total="table_modal_total"
                              @on-change="bzTjPageChange" placement="top" class="page"></Page>
                        </Col>
                    </Row>
                </Row>
            </div>

        </Modal>
    </div>
</template>
<script>
    import productTitle from "../../components/productTitle";

    //老
    //import { getComlist} from '../../api/parter';
    //import { create , get_third_pro_list , getThirdProDetail ,get_all ,update ,get_third_pro_detail
    //,get_detail } from '../../api/product_v2';
    //import { get_cate_first ,get_cate_second ,getCompany1,_all_company , } from '../../api/parter';
    //

    //新
    // _pro_third_info
    import {
        _get_parter_list,
        _pro_third_list,
        _pro_third_info,
        _create,
        _cate_first,
        _cate_list,
        _cate_delete,
        _cate_create,
        _cate_update,
        _cate_info2
    } from "../../api/product_v2";
    import {getStsTokenWrite, getStsTokenRead} from "../../api/common";

    import {_pro_third_info2, _create2} from "../../api/pro_show";

    import {
        get_pay_period,
        get_period,
        get_list2,
        get_pros,
        create3,
        update3,
        get_one,
        pro_info,
        add_addi,
        get_cate,
        create_cate,
        update_cate,
        remove_cate,
        get_cate_one,
        get_cate_two
    } from "../../api/product_v2";
    import UE from "../UE/ue.vue";
    import "../../../static/UEdit/ueditor.config.js";
    import "../../../static/UEdit/ueditor.all.js";
    import "../../../static/UEdit/lang/zh-cn/zh-cn.js";
    import "../../../static/UEdit/ueditor.parse.js";
    //交费期间  趸交   1年交   2年交   3年交   4年交   5年交   6年交   7年交   8年交   9年交  11年交   10年交   13年交   18年交   16年交   12年交   26年交   15年交  25年交   24年交   17年交   14年交   22年交   28年交   21年交   23年交  20年交   19年交   27年交   30年交   29年交   年交至9周岁   年交至15周岁  年交至14周岁   年交至12周岁   年交至16周岁   年交至17周岁   年交至18周岁  年交至20周岁   年交至25周岁   年交至30周岁   年交至35周岁   年交至40周岁  年交至45周岁   年交至50周岁   年交至55周岁   年交至59周岁   年交至60周岁  年交至64周岁   年交至65周岁   年交至69周岁   年交至70周岁   年交至75周岁  年交至80周岁   年交至85周岁   年交至90周岁   年交至95周岁   年交至100周岁  年交至105周岁   年交至终身
    //保险期间  1-7天   1天30天   2天   180天   90天   1年   2年   3年   4年   5年  6年   7年   8年   9年   11年   10年   12年   13年   14年   15年   17年  19年   18年   16年   20年   21年   22年   23年   25年   27年   24年  30年   29年   28年   26年   40年   35年   39年   50年   至14周岁  至17周岁   至18周岁   至19周岁   至20周岁   至21周岁   至22周岁   至23周岁  至24周岁   至25周岁   至28周岁   至30周岁   至35周岁   至40周岁   至45周岁  至50周岁   至54周岁   至55周岁   至59周岁   至60周岁   至66周岁   至64周岁  至65周岁   至70周岁   至75周岁   至80周岁   至81周岁   至77周岁   至85周岁  至90周岁   至88周岁   至99周岁   至100周岁   至105周岁   至106周岁   终身

    export default {
        data() {
            return {
                bz_tuijian_form: {
                    is_main: '2',
                    name: '',
                    p: 1,
                    cid: ''
                },
                bz_must_form: {
                    is_main: '2',
                    name: '',
                    p: 1,
                    cid: ''
                },
                must_tuijian_modal_form: {
                    is_main: '2',
                    name: '',
                    p: 1,
                    cid: ''
                },
                must_pro_modal_form: {
                    is_main: '2',
                    name: '',
                    p: 1,
                    cid: ''
                },
                columns3: [
                    {
                        type: 'index',
                        title:'序号',
                        width: '80',
                        align: 'center'
                    },
                    {
                        key: 'name',
                        title: '产品名称',
                        align: 'center'
                    },
                    {
                        title: '操作',
                        width: '80',
                        align: 'center',
                        render: (h, params) => {
                            return h('div', [
                                h('button', {
                                    style: {
                                        backgroundColor: '#2d8cf0',
                                        border: 'none',
                                        padding: '3px 5px',
                                        fontSize: '12px',
                                        color: '#FFF'
                                    },
                                    on: {
                                        click: () => {
                                            if (this.plans == 3) {
                                                this.plan[this.plans_index].main_pro.push({
                                                    pro_mid: params.row.id,
                                                    name: params.row.name
                                                });
                                                this.proform.plan[this.plans_index].main_pro.push(params.row.id);
                                                this.more_must_modal = false;

                                            } else if (this.plans == 4) {
                                                this.plan[this.plans_index].addi_pro.push({
                                                    pro_mid: params.row.id,
                                                    name: params.row.name
                                                });
                                                this.proform.plan[this.plans_index].addi_pro.push(params.row.id);
                                                this.more_addi_modal = false;
                                            }
                                        }
                                    },

                                }, '导入')
                            ])
                        }
                    }
                ],
                plans_index: 0,
                //保障计划  必选、推荐附加险
                plans: 0,  //1、计划必选   2、计划推荐  3、保障必选  4、保障推荐
                table_modal_total: 0,
                columns2: [
                    {
                        type: 'index',
                        title:'序号',
                        width: '80',
                        align: 'center'
                    },
                    {
                        key: 'name',
                        title: '产品名称',
                        align: 'center'
                    },
                    {
                        title: '操作',
                        width: '80',
                        align: 'center',
                        render: (h, params) => {
                            return h('div', [
                                h('button', {
                                    style: {
                                        backgroundColor: '#2d8cf0',
                                        border: 'none',
                                        padding: '3px 5px',
                                        fontSize: '12px',
                                        color: '#FFF'
                                    },
                                    on: {
                                        click: () => {
                                            if (this.plans == 1) {
                                                this.must_pro.push({pro_mid: params.row.id, name: params.row.name});
                                                this.proform.must_pro.push(params.row.id);
                                                this.must_pro_modal = false;
                                            } else if (this.plans == 2) {
                                                this.non_must_pro.push({pro_mid: params.row.id, name: params.row.name});
                                                this.proform.non_must_pro.push(params.row.id);
                                                this.addi_pro_modal = false;
                                            }
                                        }
                                    },

                                }, '导入')
                            ])
                        }
                    }
                ],
                sole_bixuan: [],
                sole_tuijian: [],
                more_must_modal: false,
                more_addi_modal: false,
                must_pro_modal: false,
                addi_pro_modal: false,
                //产品模态框  开始
                listTotal: 10,
                prolist: [],
                columns1: [
                    {
                        type: 'index',
                        title:'序号',
                        width: '80',
                        align: 'center'
                    },
                    {
                        key: 'name',
                        title: '产品名称',
                        align: 'center'
                    },
                    {
                        title: '操作',
                        width: '80',
                        align: 'center',
                        render: (h, params) => {
                            return h('div', [
                                h('button', {
                                    style: {
                                        backgroundColor: '#2d8cf0',
                                        border: 'none',
                                        padding: '3px 5px',
                                        fontSize: '12px',
                                        color: '#FFF'
                                    },
                                    on: {
                                        click: () => {
                                            // this.$refs['proform'].resetFields();
                                            this.proform.pid = params.row.id;
                                            this.proform.name = params.row.name;
                                            this.namechange();
                                        }
                                    },

                                }, '导入')
                            ])
                        }
                    }
                ],
                pro_modal_form: {
                    is_main: '',
                    shortn: '',
                    p: 1,
                    pagesize:10,
                },
                pro_modal: false,
                // 产品结束
                period: {
                    //所有保险期间
                    all_period: [],
                    //所有交费期间
                    all_pay_period: []
                },
                single: false,
                modal2: false,
                modal3: false,
                fenleiArray: [],
                xianshi: -1,
                bianji: -1,
                bianjiTwo: -1,
                bianjiCont: "",
                bianjiCont1: "",
                fenleiForm: {
                    pid: "0",
                    name: ""
                },
                cateFirst: [],
                zhedie: "1",
                modal1: false,
                //推荐附加险提示
                tuijianTitle: "",
                cate: " ",

                // tag 内容暂存位置
                //交费方式
                pay_typeCont: "",
                //标签
                labelCont: "",
                //特色
                specialTitle: "",
                specialCont: "",
                //条件
                conditionTitle: "",
                conditionCont: "",
                //推荐附加险
                additional_id: "",
                additional_name: "",
                plan: [
                    {
                        plan_type: "",
                        main_pro: [],
                        addi_pro: []
                    }
                ],
                must_pro: [],
                non_must_pro: [],
                proform: {
                    cid: "", //所属公司cid
                    company: '',
                    parter_mid: '',//所属公司  mongo  id
                    name: "",
                    mid: '',
                    pid: "0",
                    shortn: "",
                    pro_no: "",
                    plan_name: "",
                    is_short: '',
                    pdf_path:'',
                    cate_one: "  ",
                    cate_two: "  ",
                    is_main: "1",
                    insurance_period: [],
                    pay_period: [],
                    period: [],
                    pay_type: [],
                    condition: [],
                    status: "1",
                    label: [],
                    special: [],
                    additional: [],
                    is_new: "0",
                    is_rec: "0",
                    is_net: "0",
                    // is_hot: "0",
                    //依附主險计划
                    has_plan: "",
                    has_radio:'',
                    has_fee:'',
                    is_show:'',
                    must_pro: [],
                    non_must_pro: [],
                    plan: [
                        {
                            plan_type: "",
                            main_pro: [],
                            addi_pro: []
                        }
                    ],
                    limit_age: '',


                    //推荐附加险  必选附加险  唯一


                },
                all: [], //所有公司
                three_pro: [], //第三方
                ruleValidate: {
                    pid: [{required: true, message: "不能为空"}],
                    cid: [{required: true, message: "不能为空"}],
                    name:[
                        {required: true, message: "不能为空"}
                    ],
                    //                 pro_no: [
                    //                     { required: true, message: '不能为空' }
                    //                 ],
                    status: [{required: true, message: "不能为空"}]
                }
            };
        },
        components: {
            productTitle,
            UE
        },
        created() {
            this.get_pay_period();
            this.get_period();
            this.getall();
            this.cate_first();
            this.cate_list();
        },
        activated() {
        },
        methods: {
            pdfFile1(e) {
                var file = e.target.files[0];
                if (!/\.(pdf|doc|docx)$/.test(e.target.value)) {
                    alert("文件类型必须是pdf,word中的一种");
                    return false;
                }
                const pdf = document.getElementById("pdfFile");
                let files = pdf.files[0];
                getStsTokenWrite().then(res => {
                    if (res.data.err == 0) {
                        var sts = res.data.data.Credentials;
                        var client = new OSS.Wrapper({
                            region: "oss-cn-hangzhou",
                            accessKeyId: sts.AccessKeyId,
                            accessKeySecret: sts.AccessKeySecret,
                            stsToken: sts.SecurityToken,
                            bucket: "kuaibao-imgs",
                            secure: true,
                        });
                        console.log(client);
                        client.multipartUpload(files.name, files, {}).then(results => {
                            if (file.size > 100) {
                                this.proform.pdf_path = "";
                                this.proform.pdf_name = "";

                                this.proform.pdf_path = results.res.requestUrls[0].split("?")[0];
                                this.proform.pdf_name = files.name;
                            } else if (results.url) {
                                this.proform.pdf_path = "";
                                this.proform.pdf_name = "";
                                this.proform.pdf_name = files.name;
                                this.proform.pdf_path = results.url;
                            } else {
                                alert("上传失败！");
                                return false;
                            }
                        });
                    }
                });
            },
            pdfFile() {
                let pdf = document.getElementById("pdfFile");
                pdf.click();
            },
            //富文本内容获取
            getUEContent() {
                this.proform.clause = this.$refs.clause.getUEContent();
                this.proform.rule = this.$refs.rule.getUEContent();
                this.proform.illness = this.$refs.illness.getUEContent();
                this.proform.cases = this.$refs.cases.getUEContent();
                this.proform.exclusion = this.$refs.exclusion.getUEContent();
                this.proform.rights = this.$refs.rights.getUEContent();
                this.proform.description = this.$refs.description.getUEContent();
            },
            additionalChange(value) {
                this.additional_id = value.value;
                this.additional_name = value.label;
            },
            //   推荐附加险
            add_additional() {
                let can = false;
                new Promise((rev, rej) => {
                    this.proform.additional_recommend.map(item => {
                        if (item.id == this.additional_id) {
                            can = true;
                            alert("已经添加");
                            this.additional_id = "";
                            this.additional_name = "";
                            return false;
                        }
                    });
                    rev();
                }).then(() => {
                    if (!can) {
                        this.proform.additional_recommend.push({
                            id: this.additional_id,
                            name: this.additional_name
                        });
                        this.additional_id = "";
                        this.additional_name = "";
                    }
                });
            },
            remove_additional(index) {
                this.proform.additional_recommend.splice(index, 1);
            },
            //        获取所有公司
            getall() {
                new Promise((resolve, reject) => {
                    _get_parter_list()
                        .then(res => {
                            if (res.data.err == 0) {
                                this.all = [];
                                this.all = res.data.data;
                            } else {
                                this.$Message.error("供应商" + res.data.info);
                            }
                            resolve();
                        })
                        .catch(error => {
                            reject(error);
                        });
                });
            },
            //保险公司切换
            comChange(value) {
                this.proform.cid = value;
                this.proform.parter_mid = this.all[value].id;
                this.proform.name = "";
            },
            //点击导入
            comChange1() {
                if(!this.proform.cid){
                    this.$Message.error('请先选择供应商');
                    return false;
                }
                this.pro_modal_form.p=1;
                this.pro_modal_form.is_main='';
                this.pro_modal_form.shortn='';
                let _params = {
                    cid: this.proform.cid,
                };
                new Promise((resolve, reject) => {
                    get_pros(_params)
                        .then(response => {
                            if (response.data.err == 0) {
                                this.pro_modal = true;
                                this.prolist = response.data.data.list;
                                this.listTotal = response.data.data.total;
                                console.log(response.data.data.total);
                            } else {
                                this.$Message.error("产品名称" + response.data.info);
                            }
                            resolve();
                        })
                        .catch(error => {
                            reject(error);
                        });
                });
            },
            //产品切换

            namechange() {
                // console.log(this.proform.cid+'1234'+this.proform.name);
                let params = {
                    pid: this.proform.pid
                };
                new Promise((resolve, reject) => {
                    pro_info(params)
                        .then(res => {
                            if (res.data.err == 0) {
                                this.pro_modal = false;
                                this.proform.shortn = res.data.data.short_name;
                                console.log(res.data.data);
                                this.proform.period = res.data.data.insurance_period;
                                this.proform.pay_period = res.data.data.pay_period;
                                this.proform.pdf_path = res.data.data.pdf_path;

                                // this.proform.pro_no = res.data.data.pro_no;
                                this.proform.limit_age = res.data.data.imit_age_name;


                                 this.proform.has_radio = res.data.data.has_radio;
                                this.proform.has_fee = res.data.data.has_fee;
                                this.proform.is_show = res.data.data.is_show;
                                // this.proform.type = res.data.data.type;

                                this.proform.is_main = res.data.data.is_main?res.data.data.is_main.toString():'1';

                                this.proform.status = res.data.data.status?res.data.data.status.toString():'1';
                                // this.proform.is_new = res.data.data.is_new?res.data.data.is_new.toString():'0';
                                // this.proform.is_rec = res.data.data.is_rec?res.data.data.is_rec.toString():'0';
                                // this.proform.is_hot = res.data.data.is_hot?res.data.data.is_hot.toString():'0';
                                // this.proform.is_net = res.data.data.is_net?res.data.data.is_net.toString():'0';


                                this.proform.plan_name = res.data.data.plan_name;

                                this.proform.rights = res.data.data.rights ? res.data.data.rights : '';
                                this.$refs.rights.setUEContent(this.proform.rights);

                                this.proform.description = res.data.data.description ? res.data.data.description : '';
                                this.$refs.description.setUEContent(this.proform.description);

                                this.proform.rule = res.data.data.rule ? res.data.data.rule : '';
                                this.$refs.rule.setUEContent(this.proform.rule);

                                this.proform.exclusion = res.data.data.exclusion ? res.data.data.exclusion : '';
                                this.$refs.exclusion.setUEContent(this.proform.exclusion);

                                this.proform.cases = res.data.data.cases ? res.data.data.cases : '';
                                this.$refs.cases.setUEContent(this.proform.cases);

                                this.proform.clause = res.data.data.clause ? res.data.data.clause : '';
                                this.$refs.clause.setUEContent(this.proform.clause);

                                this.proform.illness = res.data.data.illness ? res.data.data.illness : '';
                                this.$refs.illness.setUEContent(this.proform.illness);
                                
                                this.proform.limit_age = res.data.data.limit_age_name;

                                // if(res.data.data.limit_age){
                                //     let limit_age = res.data.data.limit_age.split(',');
                                //     this.proform.limit_age = limit_age[0]+'-'+limit_age[limit_age.length-1]+'周岁';
                                // }
                            } else {
                                this.$Message.error(res.data.info);
                            }
                            resolve();
                        })
                        .catch(error => {
                            reject(error);
                        });
                });
            },

            //一级分类change
            first_class_change() {
                let first_class_id = {
                    id: this.proform.cate_one
                };
                new Promise((resolve, reject) => {
                    get_cate_second(first_class_id)
                        .then(res => {
                            if (res.data.err == 0) {
                                this.cate_two_list = res.data.data;
                            } else {
                                this.$Message.error(res.data.info);
                            }
                            resolve();
                        })
                        .catch(error => {
                            reject(error);
                        });
                });
            },
            //条件
            conditionAdd() {
                if (this.conditionTitle.length > 0 && this.conditionCont.length > 0) {
                    this.proform.condition.push({
                        key: this.conditionTitle,
                        val: this.conditionCont
                    });
                    this.conditionTitle = "";
                    this.conditionCont = "";
                }
            },
            conditionRemove(index) {
                this.proform.condition.splice(index, 1);
            },

            //特色
            specialAdd() {
                if (this.specialTitle.length > 0) {
                    this.proform.special.push({
                        key: this.specialTitle,
                        val: this.specialCont
                    });
                }
                this.specialTitle = "";
                this.specialCont = "";
            },
            specialRemove(index) {
                this.proform.special.splice(index, 1);
            },

            //交费方式
            pay_typeAdd() {
                if (this.pay_typeCont.length > 0) {
                    this.proform.pay_type.push(this.pay_typeCont);
                    this.pay_typeCont = "";
                }
            },
            pay_typeRemove(event, name) {
                const index = this.proform.pay_type.indexOf(name);
                this.proform.pay_type.splice(index, 1);
            },
            // 标签
            labeladd() {
                if (this.labelCont.length > 0) {
                    this.proform.label.push(this.labelCont);
                    this.labelCont = "";
                } else {
                    this.labelCont = "";
                }
            },
            labelremove(event, name) {
                const index = this.proform.label.indexOf(name);
                this.proform.label.splice(index, 1);
            },
            sendAll(name) {
                this.proform.has_plan = this.proform.has_plan ? 1 : 0;
                this.proform.has_radio = this.proform.has_radio ? 1 : 0;
                this.proform.has_fee = this.proform.has_fee ? 1 : 0;
                this.proform.is_show = this.proform.is_show ? 1 : 0;
                this.proform.is_short = this.proform.is_short ? 1 : 0;

                new Promise((resolve, rejecct) => {
                    create3(this.proform)
                        .then(res => {
                            if (res.data.err == 0) {
                                this.$router.push({name: "pro"});
                            } else {
                                this.$Message.error(res.data.info);

                            }
                            resolve();
                        })
                        .catch(error => {
                            rejecct(error);
                        });
                });
            },
            handleSubmit(name) {
                this.getUEContent();
                this.$refs[name].validate(valid => {
                    if (valid) {
                        this.sendAll();
                    } else {
                        this.$Message.error("请完善信息!");
                    }
                });
            },
            back() {
                this.$router.push({name: "pro"});
            },
            fenModal() {
                this.modal1 = true;
            },
            true1(val) {
                if (this.xianshi == val) {
                    this.xianshi = -1;
                    this.bianji = -1;
                    this.bianjiTwo = -1;
                    this.bianjiCont1 = "";
                    this.bianjiCont = "";
                } else {
                    this.xianshi = val;
                }
            },
            delete1(id) {
                let params = {
                    id: id
                };
                new Promise((resolve, rejecct) => {
                    remove_cate(params)
                        .then(res => {
                            if (res.data.err == 0) {
                                this.cate_list();
                                this.cate_first();
                                this.$Message.success("操作成功！");
                            } else {
                                this.$Message.error(res.data.info);
                            }
                            resolve();
                        })
                        .catch(error => {
                            rejecct(error);
                        });
                });
            },
            bianji1(val, id) {
                if (this.bianji == val) {
                    this.bianji = -1;
                    this.cate_update(id, this.bianjiCont);
                    let _this = this;
                    setTimeout(function () {
                        _this.cate_list();
                        _this.bianjiCont = "";
                    }, 1000);

                    // this.$set('fenleiArray',this.fenleiArray);
                } else {
                    this.bianji = val;
                    this.bianjiCont = this.fenleiArray[val].name;
                    // console.log(this.ceshi[val].zhu.name)
                }
            },
            bianji2(val, val1, id) {
                if (this.bianjiTwo == val1) {
                    this.bianjiTwo = -1;
                    this.cate_update(id, this.bianjiCont1);
                    let _this = this;
                    setTimeout(function () {
                        _this.cate_list();
                        _this.bianjiCont1 = "";
                    }, 1000);
                } else {
                    this.bianjiCont1 = this.fenleiArray[val].son[val1].name;
                    this.bianjiTwo = val1;
                }
            },
            //获取分类
            cate_list() {
                new Promise((resolve, rejecct) => {
                    get_cate()
                        .then(res => {
                            if (res.data.err == 0) {
                                this.fenleiArray = res.data.data.list;
                            } else {
                                this.$Message.error(res.data.info);
                            }
                            resolve();
                        })
                        .catch(error => {
                            rejecct(error);
                        });
                });
            },
            //一级分类
            cate_first() {
                new Promise((resolve, rejecct) => {
                    get_cate_one()
                        .then(res => {
                            if (res.data.err == 0) {
                                this.cateFirst = res.data.data.list;
                            } else {
                                this.$Message.error(res.data.info);
                            }
                            resolve();
                        })
                        .catch(error => {
                            rejecct(error);
                        });
                });
            },
            //新增分类
            cate_create() {
                if(this.fenleiForm.name){
                    new Promise((resolve, rejecct) => {
                    create_cate(this.fenleiForm)
                        .then(res => {
                            if (res.data.err == 0) {
                                this.$Message.success("操作成功");
                                this.cate_list();
                                this.cate_first();
                                this.fenleiForm.pid = "";
                                this.fenleiForm.name = "";
                            } else {
                                this.$Message.error(res.data.info);
                            }
                            resolve();
                        })
                        .catch(error => {
                            rejecct(error);
                        });
                });
                }else{
                    this.$Message.error('请填写分类名称');
                }
                
            },
            //修改分类
            cate_update(id, name) {
                let params = {
                    id: id,
                    name: name
                };
                new Promise((resolve, rejecct) => {
                    update_cate(params)
                        .then(res => {
                            if (res.data.err == 0) {
                                setTimeout(()=>{
                                    this.$Message.success('操作成功');
                                     this.cate_first();
                                },1000)
                            } else {
                                this.$Message.error(res.data.info);
                            }
                            resolve();
                        })
                        .catch(error => {
                            rejecct(error);
                        });
                });
            },
            fenleichange(val) {
                let params = {
                    cate_id: val
                };
                new Promise((resolve, rejecct) => {
                    _cate_info2(params)
                        .then(res => {
                            if (res.data.err == 0) {
                                this.proform.cate_one = res.data.data[0].pid;
                                this.proform.cate_two = res.data.data[0].id;
                            } else {
                                this.$Message.error(res.data.info);
                            }
                            resolve();
                        })
                        .catch(error => {
                            rejecct(error);
                        });
                });
            },
            handleClose2() {
                this.proform.pdf_path = "";
                this.proform.pdf_name = "";
            },
            cateChange(val) {

                if (val.label.split("-----")[1]) {
                    this.fenleichange(val.value);
                } else {
                    this.proform.cate_one = val.value;
                    this.proform.cate_two = "";
                }
            },
            shanchu(obj, index) {
                this.proform[obj].splice(index, 1);
            },
            //附加险 删除
            shanchu1(obj, index,index1) {
                if(obj=='must_pro'){
                    this.must_pro.splice(index,1);
                    this.proform[obj].splice(index, 1);
                }else if(obj=='non_must_pro'){
                    this.non_must_pro.splice(index,1);
                    this.proform[obj].splice(index, 1);
                }else if(obj=='more_must'){
                    this.plan[index].main_pro.splice(index1,1);
                    this.proform.plan[index].main_pro.splice(index1, 1);
                }else if(obj=='more_no_must'){
                    this.plan[index].addi_pro.splice(index1,1);
                    this.proform.plan[index].addi_pro.splice(index1, 1);
                }
            },
            periodClick() {
                this.modal2 = true;
            },
            payPeriodClick() {
                this.modal3 = true;
            },
            //获取交费期间   保险期间
            get_pay_period() {
                new Promise((resolve, rejecct) => {
                    get_pay_period()
                        .then(res => {
                            if (res.data.err == 0) {
                                this.period.all_pay_period = res.data.data;
                            } else {
                                this.$Message.error(res.data.info);
                            }
                            resolve();
                        })
                        .catch(error => {
                            rejecct(error);
                        });
                });
            },
            get_period() {
                new Promise((resolve, rejecct) => {
                    get_period()
                        .then(res => {
                            if (res.data.err == 0) {
                                this.period.all_period = res.data.data;
                                //    this.$set(period,'all_period', res.data.data)
                            } else {
                                this.$Message.error(res.data.info);
                            }
                            resolve();
                        })
                        .catch(error => {
                            rejecct(error);
                        });
                });
            },
            addPlan() {
                this.plan.push({
                    plan_type: "",
                    main_pro: [],
                    addi_pro: []
                });
                this.proform.plan.push({
                    plan_type: "",
                    main_pro: [],
                    addi_pro: []
                });
            },

            tableCurrentChange(val) {
                this.proform.pid = val.id;
                this.proform.name = val.name;
            },
            pageChange(val,) {
                this.pro_modal_form.p = val;
                this.pro_modal_form.cid = this.proform.cid;
                new Promise((resolve, reject) => {
                    get_pros(this.pro_modal_form)
                        .then(response => {
                            if (response.data.err == 0) {
                                this.pro_modal = true;
                                this.prolist = response.data.data.list;
                            } else {
                                this.$Message.error("产品名称" + response.data.info);
                            }
                            resolve();
                        })
                        .catch(error => {
                            reject(error);
                        });
                });
            },
            pro_search() {
                this.pro_modal_form.cid = this.proform.cid;
                this.pro_modal_form.p = 1;
                new Promise((resolve, reject) => {
                    get_pros(this.pro_modal_form)
                        .then(response => {
                            if (response.data.err == 0) {
                                this.pro_modal = true;
                                this.prolist = response.data.data.list;
                                this.listTotal = response.data.data.total;
                            } else {
                                this.$Message.error("产品名称" + response.data.info);
                            }
                            resolve();
                        })
                        .catch(error => {
                            reject(error);
                        });
                });
            },

            add_must_pro() {
                this.must_pro_modal_form.cid = this.proform.cid
                this.plan_must_search();
            },

            add_non_must_pro() {
                this.must_tuijian_modal_form.cid = this.proform.cid
                this.plan_must_tuijian();
            },
            add_more_must(index) {
                // let params = {
                //     cid:this.proform.cid,
                //     is_main:2
                // }
                // this.bz_must_form.cid = this.proform.cid;
                this.bz_must_form.cid = this.proform.cid;
                new Promise((resolve, reject) => {
                    add_addi(this.bz_must_form)
                        .then(response => {
                            if (response.data.err == 0) {
                                this.sole_bixuan = response.data.data.list;
                                this.table_modal_total = response.data.data.total;
                                this.sole_tuijian = response.data.data.list;
                            } else {
                                this.$Message.error("推荐附加险" + response.data.info);
                            }
                            resolve();
                            this.more_must_modal = true;
                            this.plans = 3;
                            this.plans_index = index;
                        })
                        .catch(error => {
                            reject(error);
                        });
                });
            },
            add_more_tuijian(index) {
                // let params = {
                //     cid:this.proform.cid,
                //     is_main:2
                // }
                this.bz_tuijian_form.cid = this.proform.cid;
                new Promise((resolve, reject) => {
                    add_addi(this.bz_tuijian_form)
                        .then(response => {
                            if (response.data.err == 0) {
                                this.sole_bixuan = response.data.data.list;
                                this.table_modal_total = response.data.data.total;
                                this.sole_tuijian = response.data.data.list;
                            } else {
                                this.$Message.error("推荐附加险" + response.data.info);
                            }
                            resolve();
                            this.more_addi_modal = true;
                            this.plans = 4;
                            this.plans_index = index;
                        })
                        .catch(error => {
                            reject(error);
                        });
                });
            },
            isMain(val) {
                if (val == 2) {
                    this.proform.has_plan = 0;
                    this.proform.must_pro = [];
                    this.proform.non_must_pro = [];
                } else if (val == 3) {
                    this.proform.has_plan = 0;
                    this.proform.plan = [{
                        plan_type: '',
                        main_pro: [],
                        addi_pro: []
                    }];
                }
            },
            //计划书   必选附加险  搜索功能
            plan_must_search() {
                new Promise((resolve, reject) => {
                    add_addi(this.must_pro_modal_form)
                        .then(response => {
                            if (response.data.err == 0) {
                                this.sole_bixuan = response.data.data.list;
                                this.table_modal_total = response.data.data.total;
                                this.sole_tuijian = response.data.data.list;
                            } else {
                                this.$Message.error("必选附加险" + response.data.info);
                            }
                            resolve();
                            this.must_pro_modal = true;
                            this.plans = 1;
                        })
                        .catch(error => {
                            reject(error);
                        });
                });
            },
            //计划书   必选附加险  点击搜索
            plan_must_search_click() {
                this.must_pro_modal_form.p = 1;
                this.plan_must_search();
            },
            //计划书   必选附加险  page页码改变
            planMustPageChange(val) {
                this.must_pro_modal_form.p = val;
                this.plan_must_search();
            },


            //计划书   推荐附加险  搜索功能
            plan_must_tuijian() {
                new Promise((resolve, reject) => {
                    add_addi(this.must_tuijian_modal_form)
                        .then(response => {
                            if (response.data.err == 0) {
                                this.sole_bixuan = response.data.data.list;
                                this.table_modal_total = response.data.data.total;
                                this.sole_tuijian = response.data.data.list;

                            } else {
                                this.$Message.error("推荐附加险" + response.data.info);
                            }
                            resolve();
                            this.addi_pro_modal = true;
                            this.plans = 2;
                        })
                        .catch(error => {
                            reject(error);
                        });
                });
            },
            //计划书   推荐附加险  点击搜索
            plan_tuijian_search_click() {
                this.must_tuijian_modal_form.p = 1;
                this.plan_must_tuijian();
            },
            //计划书   推荐附加险  page页码改变
            planTuijianPageChange(val) {
                this.must_tuijian_modal_form.p = val;
                this.plan_must_tuijian();
            },
            //保障计划   必选附加险  搜索功能
            bz_must_search() {
                new Promise((resolve, reject) => {
                    add_addi(this.bz_must_form)
                        .then(response => {
                            if (response.data.err == 0) {
                                this.sole_bixuan = response.data.data.list;
                                this.table_modal_total = response.data.data.total;
                                this.sole_tuijian = response.data.data.list;
                            } else {
                                this.$Message.error("推荐附加险" + response.data.info);
                            }
                            resolve();
                        })
                        .catch(error => {
                            reject(error);
                        });
                });
            },
            //保障计划   必选附加险  点击搜索
            bz_must_search_click() {
                this.bz_must_form.p = 1;
                this.bz_must_search();
            },
            //保障计划   必选附加险  page页码改变
            bzMustPageChange(val) {
                this.bz_must_form.p = val;
                this.bz_must_search();
            },
            //保障计划   推荐附加险  搜索功能
            bz_tuijian_search() {
                new Promise((resolve, reject) => {
                    add_addi(this.bz_tuijian_form)
                        .then(response => {
                            if (response.data.err == 0) {
                                this.sole_bixuan = response.data.data.list;
                                this.table_modal_total = response.data.data.total;
                                this.sole_tuijian = response.data.data.list;
                            } else {
                                this.$Message.error("推荐附加险" + response.data.info);
                            }
                            resolve();
                        })
                        .catch(error => {
                            reject(error);
                        });
                });
            },
            //保障计划   推荐附加险  点击搜索
            bz_tuijian_search_click() {
                this.bz_tuijian_form.p = 1;
                this.bz_tuijian_search();
            },
            //保障计划   推荐附加险  page页码改变
            bzTjPageChange(val) {
                this.bz_tuijian_form.p = val;
                this.bz_tuijian_search();
            },
            seePdf(){
                window.open(this.proform.pdf_path);     
            }

        },
        beforeRouteLeave(to, from, next) {
            if (!this.$route.params.id) {
                to.meta.keepAlive = false;
                next();
            }
        },
        mounted() {
        }
    };
</script>

